{% if data.report_items|length != 1 -%}
This Template needs exactly one Report
{% else -%}
{% set report = data.report_items[0].attributes.Data -%}
{% set stories = data.report_items[0].stories -%}

<!doctype html>
<html lang="de">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>CERT.at  - Tageszusammenfassung</title>
    <link rel="stylesheet" href="https://cert.at/css/app.css">
  </head>
  <body>
    <div class="container-fluid stage bg-shadow">
      <div class="container stage-push-top stage-domain-statiskten stage-body content-section" role="main">
      <div class="row">
      <div class="col-sm-12">
        <h1>Tageszusammenfassung - {{ report.date | default('') }}</h1>
        <h2>End-of-Day report</h2>
          Timeframe:   {{ report.timeframe | default('') }}
          Handler:     {{ report.handler | default('') }}
          Co-Handler:  {{ report.co_handler | default('') }}

        {% for group in ['News' , 'Vulnerabilities'] -%}
        <h2> {{ group }} </h2>
        {% set story_ids_in_group = report.get(group.lower()) %}
        STORIES IN GROUP: {{ story_ids_in_group }}
        {% if story_ids_in_group %}
          {% set story_ids = story_ids_in_group.split(',') %}
          {% for story_id in story_ids -%}
            {% set story = stories | selectattr('id', 'equalto', story_id) | first %}
            {% if story %}
              <h3>{{ story.title }}</h3>
              <p>
                {% if story.summary|length -%}
                  {{ story.summary }}
                {% else -%}
                  {{ story.news_items[0].content }}
                {%- endif %}
              </p>

              {% for item in story.news_items -%}
                <p><a href="{{ item.link }}">{{ item.link }}</a></p>
              {% endfor %}
              <hr>
            {% endif %}
          {% endfor %}
        {% endif %}
      {% endfor %}
      </div>
      </div>
      </div>
    </div>
  </body>
</html>
{% endif -%}
